<?php
/**
 *   Joomdiet - components/views/foodsearch/view.html.php
 *   Author: Juan Dapena Paz (juan@bittingbits.com)
 *   Copyright (C) 2010 Bitting Bits S.L.
 *
 *   This program is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
defined('_JEXEC') or die('Restricted access');
jimport('joomla.application.component.view');
JHTML::_('behavior.mootools');

class JoomdietViewFoodSearch extends JView
{
    function display($tpl=null)
    {
        $menu = JoomdietHelperFrontMenu::getInstance();
        echo $menu->display();
        
        // loading variables
        $advanced = JRequest::getVar('advanced');
        $categories = $this->get('Data', 'FoodCategory');
        $selected_category_id = JRequest::getVar('food_subcategory');
        if ($selected_category_id) {
            $food_category_model = $this->get('Model', 'FoodCategory');
            $subcategories = 
                $food_category_model->getChilds($selected_category_id);
        }
        $variables = $this->get('Data', 'Variable');
        
        //variable assignment
        $this->assignRef('advanced', $advanced);
        $this->assignRef('categories', $categories);
        $this->assignRef('subcategories', $subcategories);
        $this->assignRef('categoryid', $selected_category_id);
        $this->assignRef('variables', $variables);
        
        parent::display($tpl);
    }
}
?>
